<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vuejs-2.5.16.js"></script>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/getParameter.js"></script>

</head>
<body>
<div id="d1">
    <h1 align="center"><a href="javascript:void(0)" @click="selectBalance">账户余额查询</a></h1><br>
    <h2 align="center"><span>{{remaining}}</span></h2><br>

    <h1 align="center"><a href="javascript:void(0)" @click="show">交易记录查询</a></h1><br>
    <div :style="nature">
        <span style="color: red">{{error}}</span><br>
        <label>开始时间</label><input type="date" name="startTime" v-model="time.startTime"><br>
        <label>结束时间</label><input type="date" name="endTime" v-model="time.endTime"><br>
        <input type="submit" value="查询" @click="transactionQuery">
    </div><br>
    <table :style="ta" border="1">
        <tr>
            <td>id</td>
            <td>账号</td>
            <td>交易类型</td>
            <td>交易金额</td>
            <td>交易时间</td>
            <td>交易摘要</td>
        </tr>
        <tr v-for="(al,index) in transactions">
            <td>{{index+1}}</td>
            <td>{{al.accountID}}</td>
            <td>{{al.tradeType}}</td>
            <td>{{al.tradeMoney}}</td>
            <td>{{al.tradeToTime}}</td>
            <td>{{al.tradeDigest}}</td>
        </tr>
    </table><br>
    <h1 align="center"><a href="javascript:void(0)" @click="transfer">行内单笔转账</a></h1><br>
    <div :style="al">
        <label>转入账户</label><input type="text" name="toAccount" v-model="into.toAccount"><br>
        <label>转入金额</label><input type="text" name="money" v-model="into.money"><br>
        <input type="submit" value="转入" @click="transferTo">
    </div><br>
    <div  :style="a2">
        <h1 align="center">行内单笔转账成功</h1><br>
        <span>您已成功将{{into.money}}转入到{{into.toAccount}}</span>
    </div>

</div>

<script>
    alert("aaa")
    var accountID = getParameter("accountID")
    var password = getParameter("password")
    new Vue({
        el:"#d1",
        data:{
            remaining:"",
            nature:"display: none",
            time:{startTime:"",endTime:""},
            ta:"display: none",
            transactions:[],
            error:"",
            al:"display: none",
            into:{},
            a2:"display: none"
        },
        methods:{
            selectBalance:function () {
                var _this = this
                var params = new URLSearchParams()
                params.append("accountID",accountID)
                params.append("password",password)
                axios.post("/test/user/selectBalance.do",params).then(function (res) {
                    _this.remaining = "余额为"+res.data
                })
            },
            show:function(){
                this.nature = ""
            },
            transactionQuery:function () {
                var params = new URLSearchParams()
                params.append("accountID",accountID)
                params.append("startTime",this.time.startTime)
                params.append("endTime",this.time.endTime)
                var _this = this
                axios.post("/test/user/selectTransactions.do",params).then(function (res) {
                    if (res.data.falg) {
                        _this.ta=""

                        _this.transactions = res.data.trade
                    }else {
                        _this.ta="display: none"
                        _this.error = res.data.error
                    }
                }).catch(function (error) {
                    alert(error)
                })
            },
            transfer:function () {
                this.al = ""
                this.a2 = "display: none"
            },
            transferTo:function () {
                var _this = this;
                var params = new URLSearchParams()
                params.append("accountID",accountID)
                params.append("password",password)
                params.append("toAccount",this.into.toAccount)
                params.append("money",this.into.money)
                axios.post("/test/user/transferTo.do",params).then(function (res) {
                    if (res.data.falg) {
                        _this.al="display: none"
                        _this.a2="display: none"
                    }else {
                        alert(res.data.error)
                    }
                })
            }
        }
    })
</script>
</body>
</html>